
$(document).ready(function(e){
	page_gallery();
    page_init();
});

// ===========================================================================================

function page_init()
{
	var body_w = $(window).width()>1024 ? 600 : $(window).width() ;
	var body_h = $(window).height();
	var head_h = $(".header").height();
	var foot_h = $(".footer").height();
	
	// 页面初始化
	if( body_w < body_h )
	{
		wrap_h = body_h-head_h-foot_h-body_w*0.5-10 ;
		menu_w = (body_w-30)/2;
		menu_h = wrap_h/2-10 ;
		$(".hpmenu").height(wrap_h);
		$(".hpmenu li").height(wrap_h*0.5);
		$(".hpmenu li a").height(menu_h);
		$(".hpmenu li img").css({paddingTop:menu_h/2-40});
	}
	else
	{
		menu_h = (body_w-30)/2*0.3 ;
		$(".hpmenu li").height(menu_h);
		$(".hpmenu li a").height(menu_h-10);
		$(".hpmenu li img").css({paddingTop:menu_h/2-40});
	}
	
	// 设置城市
	$("#set_city").mmenu({extensions:["fullscreen"],offCanvas:{position:"top"}});
	$("#set_city .hd-return").click(function(){ $("#set_city").data("mmenu").close(); });
	$("#set_city .citys").height(body_h-head_h-41);
	if( $("#set_city .btns").length>0 )
	{
		$("#set_city .citys").height(body_h-head_h-41-61);
		$("#set_city ul li").click(function(){
			$(this).siblings().removeClass("selected").end().addClass("selected");
			$("#set_city .btn").removeClass("disable").addClass("selected");
		});
		$("#set_city .btns").on("click",".btn.selected",function(){ alert("City has been selected !"); });
	}
	
	// 设置频道
	$("#set_chanel").mmenu({extensions:["fullscreen"],offCanvas:{position:"top"}});
	$("#set_chanel .hd-return").click(function(){ $("#set_chanel").data("mmenu").close(); });
	$("#set_chanel .chanels").height(body_h-head_h);
}

function page_gallery()
{
	var body_w = $(window).width()>1024 ? 600 : $(window).width() ;
	
	$(".scroll,.mod_01 img").width(body_w);
	$(".mod_01 img").height(body_w*0.5);
	
	var page = $("#slide_01>div").length;
	var slide_01 = new ScrollPic();
	slide_01.scrollContId = "slide_01"; //内容容器ID
	slide_01.dotListId = "slide_01_dot";//点列表ID
	slide_01.dotOnClassName = "selected";
	slide_01.arrLeftId = "sl_left"; //左箭头ID
	slide_01.arrRightId = "sl_right";//右箭头ID
	slide_01.frameWidth = body_w;
	slide_01.pageWidth = body_w;
	slide_01.upright = false;
	slide_01.speed = 10;
	slide_01.space = 30;
	slide_01.autoPlayTime = 5;//自动播放时间
	slide_01.pageNumber = page;//页面统计
	slide_01.initialize(); //初始化
}


document.onreadystatechange=function()
{
	var body_w = $(window).width()>1024?500:$(window).width();
	var body_h = $(window).height();
	
	// 页面完全加载
	if(document.readyState=="complete")
	{
		// 隐藏遮罩，显示页面
		$(".framepage").fadeIn();
		$(".hf_overlay").fadeOut();
		$(".hf_overlay > div").fadeOut();
		
		// 页面滚动效果
		frame_pulltorefresh();
		
		// 页面特效
//		$(".header,.footer,.scroll,.hpmenu").css({opacity:0});
//		setTimeout(function(){ $(".header").css({opacity:1}).addClass("amt_slidedown"); },0);
//		setTimeout(function(){ $(".footer").css({opacity:1}).addClass("amt_slideup"); },0);
//		setTimeout(function(){ $(".scroll").css({opacity:1}).addClass("amt_slideup"); },0);
//		setTimeout(function(){ $(".hpmenu").css({opacity:1}).addClass("amt_slideup"); },500);
	}	
}
